package net.yxsoft.quorum;

import io.reactivex.Flowable;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
import org.web3j.abi.EventEncoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Event;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.Utf8String;
import org.web3j.abi.datatypes.generated.Uint32;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.DefaultBlockParameter;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.protocol.core.methods.request.EthFilter;
import org.web3j.protocol.core.methods.response.BaseEventResponse;
import org.web3j.protocol.core.methods.response.Log;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tuples.generated.Tuple4;
import org.web3j.tuples.generated.Tuple6;
import org.web3j.tx.Contract;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.ContractGasProvider;

/**
 * <p>Auto generated code.
 * <p><strong>Do not modify!</strong>
 * <p>Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>,
 * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the 
 * <a href="https://github.com/web3j/web3j/tree/master/codegen">codegen module</a> to update.
 *
 * <p>Generated with web3j version 1.4.2.
 */
@SuppressWarnings("rawtypes")
public class ModelRegistry extends Contract {
    public static final String BINARY = "Bin file was not provided";

    public static final String FUNC_CREATEMODEL = "createModel";

    public static final String FUNC_GETMODELATTRIBGROUP7 = "getModelAttribGroup7";

    public static final String FUNC_GETMODELATTRIBGROUP4 = "getModelAttribGroup4";

    public static final String FUNC_GETMODELATTRIBGROUP6 = "getModelAttribGroup6";

    public static final String FUNC_GETMODELOPT = "getModelOpt";

    public static final String FUNC_GETMODELINFO = "getModelInfo";

    public static final String FUNC_GETMODELATTRIBGROUP1 = "getModelAttribGroup1";

    public static final String FUNC_GETMODELATTRIBGROUP2 = "getModelAttribGroup2";

    public static final String FUNC_GETMODELATTRIBGROUP5 = "getModelAttribGroup5";

    public static final String FUNC_GETMODELATTRIBGROUP3 = "getModelAttribGroup3";

    public static final Event MODELGENERATED_EVENT = new Event("ModelGenerated", 
            Arrays.<TypeReference<?>>asList(new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Uint32>() {}, new TypeReference<Utf8String>() {}));
    ;

    @Deprecated
    protected ModelRegistry(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected ModelRegistry(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
    }

    @Deprecated
    protected ModelRegistry(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    protected ModelRegistry(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public RemoteFunctionCall<TransactionReceipt> createModel(BigInteger conflict_id, BigInteger row_id, BigInteger par_row_id, String created, String created_by, String last_upd, String last_upd_by, BigInteger modification_num, String eim_source, String attrib_str) {
        final Function function = new Function(
                FUNC_CREATEMODEL, 
                Arrays.<Type>asList(new Uint32(conflict_id),
                new Uint32(row_id),
                new Uint32(par_row_id),
                new Utf8String(created),
                new Utf8String(created_by),
                new Utf8String(last_upd),
                new Utf8String(last_upd_by),
                new Uint32(modification_num),
                new Utf8String(eim_source),
                new Utf8String(attrib_str)),
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    public RemoteFunctionCall<Tuple6<String, String, String, String, String, String>> getModelAttribGroup7(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELATTRIBGROUP7, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple6<String, String, String, String, String, String>>(function,
                new Callable<Tuple6<String, String, String, String, String, String>>() {
                    @Override
                    public Tuple6<String, String, String, String, String, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple6<String, String, String, String, String, String>(
                                (String) results.get(0).getValue(), 
                                (String) results.get(1).getValue(), 
                                (String) results.get(2).getValue(), 
                                (String) results.get(3).getValue(), 
                                (String) results.get(4).getValue(), 
                                (String) results.get(5).getValue());
                    }
                });
    }

    public RemoteFunctionCall<Tuple6<String, String, String, String, String, String>> getModelAttribGroup4(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELATTRIBGROUP4, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple6<String, String, String, String, String, String>>(function,
                new Callable<Tuple6<String, String, String, String, String, String>>() {
                    @Override
                    public Tuple6<String, String, String, String, String, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple6<String, String, String, String, String, String>(
                                (String) results.get(0).getValue(), 
                                (String) results.get(1).getValue(), 
                                (String) results.get(2).getValue(), 
                                (String) results.get(3).getValue(), 
                                (String) results.get(4).getValue(), 
                                (String) results.get(5).getValue());
                    }
                });
    }

    public RemoteFunctionCall<Tuple6<String, String, String, String, String, String>> getModelAttribGroup6(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELATTRIBGROUP6, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple6<String, String, String, String, String, String>>(function,
                new Callable<Tuple6<String, String, String, String, String, String>>() {
                    @Override
                    public Tuple6<String, String, String, String, String, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple6<String, String, String, String, String, String>(
                                (String) results.get(0).getValue(), 
                                (String) results.get(1).getValue(), 
                                (String) results.get(2).getValue(), 
                                (String) results.get(3).getValue(), 
                                (String) results.get(4).getValue(), 
                                (String) results.get(5).getValue());
                    }
                });
    }

    public RemoteFunctionCall<Tuple4<String, String, String, String>> getModelOpt(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELOPT, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple4<String, String, String, String>>(function,
                new Callable<Tuple4<String, String, String, String>>() {
                    @Override
                    public Tuple4<String, String, String, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple4<String, String, String, String>(
                                (String) results.get(0).getValue(), 
                                (String) results.get(1).getValue(), 
                                (String) results.get(2).getValue(), 
                                (String) results.get(3).getValue());
                    }
                });
    }

    public RemoteFunctionCall<Tuple4<BigInteger, BigInteger, BigInteger, String>> getModelInfo(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELINFO, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Uint32>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple4<BigInteger, BigInteger, BigInteger, String>>(function,
                new Callable<Tuple4<BigInteger, BigInteger, BigInteger, String>>() {
                    @Override
                    public Tuple4<BigInteger, BigInteger, BigInteger, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple4<BigInteger, BigInteger, BigInteger, String>(
                                (BigInteger) results.get(0).getValue(), 
                                (BigInteger) results.get(1).getValue(), 
                                (BigInteger) results.get(2).getValue(), 
                                (String) results.get(3).getValue());
                    }
                });
    }

    public RemoteFunctionCall<Tuple6<String, String, String, String, String, String>> getModelAttribGroup1(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELATTRIBGROUP1, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple6<String, String, String, String, String, String>>(function,
                new Callable<Tuple6<String, String, String, String, String, String>>() {
                    @Override
                    public Tuple6<String, String, String, String, String, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple6<String, String, String, String, String, String>(
                                (String) results.get(0).getValue(), 
                                (String) results.get(1).getValue(), 
                                (String) results.get(2).getValue(), 
                                (String) results.get(3).getValue(), 
                                (String) results.get(4).getValue(), 
                                (String) results.get(5).getValue());
                    }
                });
    }

    public RemoteFunctionCall<Tuple6<String, String, String, String, String, String>> getModelAttribGroup2(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELATTRIBGROUP2, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple6<String, String, String, String, String, String>>(function,
                new Callable<Tuple6<String, String, String, String, String, String>>() {
                    @Override
                    public Tuple6<String, String, String, String, String, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple6<String, String, String, String, String, String>(
                                (String) results.get(0).getValue(), 
                                (String) results.get(1).getValue(), 
                                (String) results.get(2).getValue(), 
                                (String) results.get(3).getValue(), 
                                (String) results.get(4).getValue(), 
                                (String) results.get(5).getValue());
                    }
                });
    }

    public RemoteFunctionCall<Tuple6<String, String, String, String, String, String>> getModelAttribGroup5(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELATTRIBGROUP5, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple6<String, String, String, String, String, String>>(function,
                new Callable<Tuple6<String, String, String, String, String, String>>() {
                    @Override
                    public Tuple6<String, String, String, String, String, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple6<String, String, String, String, String, String>(
                                (String) results.get(0).getValue(), 
                                (String) results.get(1).getValue(), 
                                (String) results.get(2).getValue(), 
                                (String) results.get(3).getValue(), 
                                (String) results.get(4).getValue(), 
                                (String) results.get(5).getValue());
                    }
                });
    }

    public RemoteFunctionCall<Tuple6<String, String, String, String, String, String>> getModelAttribGroup3(BigInteger conflict_id) {
        final Function function = new Function(FUNC_GETMODELATTRIBGROUP3, 
                Arrays.<Type>asList(new Uint32(conflict_id)),
                Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}, new TypeReference<Utf8String>() {}));
        return new RemoteFunctionCall<Tuple6<String, String, String, String, String, String>>(function,
                new Callable<Tuple6<String, String, String, String, String, String>>() {
                    @Override
                    public Tuple6<String, String, String, String, String, String> call() throws Exception {
                        List<Type> results = executeCallMultipleValueReturn(function);
                        return new Tuple6<String, String, String, String, String, String>(
                                (String) results.get(0).getValue(), 
                                (String) results.get(1).getValue(), 
                                (String) results.get(2).getValue(), 
                                (String) results.get(3).getValue(), 
                                (String) results.get(4).getValue(), 
                                (String) results.get(5).getValue());
                    }
                });
    }

//    public static List<ModelGeneratedEventResponse> getModelGeneratedEvents(TransactionReceipt transactionReceipt) {
//        List<Contract.EventValuesWithLog> valueList = staticExtractEventParametersWithLog(MODELGENERATED_EVENT, transactionReceipt);
//        ArrayList<ModelGeneratedEventResponse> responses = new ArrayList<ModelGeneratedEventResponse>(valueList.size());
//        for (Contract.EventValuesWithLog eventValues : valueList) {
//            ModelGeneratedEventResponse typedResponse = new ModelGeneratedEventResponse();
//            typedResponse.log = eventValues.getLog();
//            typedResponse.conflict_id = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
//            typedResponse.row_id = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
//            typedResponse.par_row_id = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
//            typedResponse.created = (String) eventValues.getNonIndexedValues().get(3).getValue();
//            typedResponse.created_by = (String) eventValues.getNonIndexedValues().get(4).getValue();
//            typedResponse.last_upd = (String) eventValues.getNonIndexedValues().get(5).getValue();
//            typedResponse.last_upd_by = (String) eventValues.getNonIndexedValues().get(6).getValue();
//            typedResponse.modification_num = (BigInteger) eventValues.getNonIndexedValues().get(7).getValue();
//            typedResponse.eim_source = (String) eventValues.getNonIndexedValues().get(8).getValue();
//            responses.add(typedResponse);
//        }
//        return responses;
//    }

    public Flowable<ModelGeneratedEventResponse> modelGeneratedEventFlowable(EthFilter filter) {
        return web3j.ethLogFlowable(filter).map(new io.reactivex.functions.Function<Log, ModelGeneratedEventResponse>() {
            @Override
            public ModelGeneratedEventResponse apply(Log log) {
                EventValuesWithLog eventValues = extractEventParametersWithLog(MODELGENERATED_EVENT, log);
                ModelGeneratedEventResponse typedResponse = new ModelGeneratedEventResponse();
                typedResponse.log = log;
                typedResponse.conflict_id = (BigInteger) eventValues.getNonIndexedValues().get(0).getValue();
                typedResponse.row_id = (BigInteger) eventValues.getNonIndexedValues().get(1).getValue();
                typedResponse.par_row_id = (BigInteger) eventValues.getNonIndexedValues().get(2).getValue();
                typedResponse.created = (String) eventValues.getNonIndexedValues().get(3).getValue();
                typedResponse.created_by = (String) eventValues.getNonIndexedValues().get(4).getValue();
                typedResponse.last_upd = (String) eventValues.getNonIndexedValues().get(5).getValue();
                typedResponse.last_upd_by = (String) eventValues.getNonIndexedValues().get(6).getValue();
                typedResponse.modification_num = (BigInteger) eventValues.getNonIndexedValues().get(7).getValue();
                typedResponse.eim_source = (String) eventValues.getNonIndexedValues().get(8).getValue();
                return typedResponse;
            }
        });
    }

    public Flowable<ModelGeneratedEventResponse> modelGeneratedEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
        EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress());
        filter.addSingleTopic(EventEncoder.encode(MODELGENERATED_EVENT));
        return modelGeneratedEventFlowable(filter);
    }

    @Deprecated
    public static ModelRegistry load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
        return new ModelRegistry(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    @Deprecated
    public static ModelRegistry load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new ModelRegistry(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    public static ModelRegistry load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
        return new ModelRegistry(contractAddress, web3j, credentials, contractGasProvider);
    }

    public static ModelRegistry load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return new ModelRegistry(contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static class ModelGeneratedEventResponse extends BaseEventResponse {
        public BigInteger conflict_id;

        public BigInteger row_id;

        public BigInteger par_row_id;

        public String created;

        public String created_by;

        public String last_upd;

        public String last_upd_by;

        public BigInteger modification_num;

        public String eim_source;
    }
}
